package com.gree.changying.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;

import androidx.annotation.Nullable;

public class BottomSheetScrollView extends ScrollView {
    public BottomSheetScrollView(Context context) {
        super(context);
    }

    public BottomSheetScrollView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public BottomSheetScrollView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()){
            case MotionEvent.ACTION_MOVE:
                if(getScrollY() == 0){
                    requestDisallowInterceptTouchEvent(false);
                    break;
                }
                requestDisallowInterceptTouchEvent(true);
                break;
        }
        return super.onTouchEvent(event);
    }
}
